# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>

pkgbase=libstrophe
pkgname=('libstrophe' 'libstrophe-doc')
pkgver=0.12.3
pkgrel=1
epoch=1
pkgdesc='Simple, lightweight C library for writing XMPP clients'
url='http://strophe.im/libstrophe/'
arch=('loong64' 'x86_64')
license=('GPL3' 'MIT')
depends=('glibc' 'openssl' 'expat')
makedepends=('doxygen')
checkdepends=('check')
source=(https://github.com/strophe/libstrophe/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('da4597faa3d277d4cf557e07a10d8974239de38a0396a545f98ea5f8c39c1e00b0de9cde56a2a438115ad07c98658859c8b623273f083ce1f642a000ecc4efde')
b2sums=('df2ec9863583397b48c36b1e8560e28e9210735fc05f8e204f8c27789069d13bdc017679427f7a969504823d43e906b0beed19da95c6efd8ceb20ff4358da8a8')

prepare() {
  cd ${pkgbase}-${pkgver}
  autoreconf -fiv
}

build() {
  cd ${pkgbase}-${pkgver}
  ./configure \
    --prefix=/usr
  make
  doxygen
}

check() {
  make -C ${pkgbase}-${pkgver} check
}

package_libstrophe() {
  depends+=('libexpat.so')
  provides=('libstrophe.so')
  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm 644 MIT-LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-MIT"
}

package_libstrophe-doc() {
  pkgdesc+=' (documentation and samples)'
  depends=()
  options=('!strip')
  optdepends=('libstrophe')
  cd ${pkgbase}-${pkgver}
  install -Dm 644 docs/html/* -t "${pkgdir}/usr/share/doc/${pkgname}/html"
  install -Dm 644 examples/{README.md,*.c} -t "${pkgdir}/usr/share/doc/${pkgname}/examples"
  install -Dm 644 MIT-LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
